package com.xggstudio.crm.ui.mvp.v;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;

import com.xggstudio.crm.R;
import com.xggstudio.crm.base.BaseActivity;

public class StartActivity  extends BaseActivity implements IStartView{
    @Override
    protected int getLayout() {
        return R.layout.activity_start;
    }

    @Override
    protected void init(Bundle savedInstanceState) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.TRANSPARENT);
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            );
        }

        handler.postDelayed(runnable,1000);
    }

    Handler handler = new Handler();
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            startMain();
        }
    };

    @Override
    public void startMain() {
        startToActivity(LoginActivity.class);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler.removeCallbacks(runnable);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if(event.getKeyCode() == KeyEvent.KEYCODE_BACK){

            return false;
        }

        return super.onKeyDown(keyCode, event);
    }
}
